package com.ncmmall.domain.business.distribution;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ncmmall.domain.business.goods.Goods;
import com.ncmmall.domain.security.user.WebUser;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

/**
 * 分销商品池
 */
@Entity
@Table(name = "distribution_goods")
@Access(AccessType.FIELD)
@Getter
@Setter
@ToString
@EqualsAndHashCode
@Accessors(chain = true)
public class DistributionGoods {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 商家
     */
    @OneToOne
    private WebUser merchant;

    /**
     * 商品
     */
    @OneToOne
    private Goods goods;

    /**
     * 分销商范围
     * 1、全部分销商
     * 2、指定分销商
     */
    private Integer distributorScope;

    /**
     * 保底佣金
     */
    private Double guaranteeScale;

    /**
     * 创建时间
     */
    private Timestamp createTime;

    /**
     * 1、已上架
     * 2、已下架
     * 3、已删除
     */
    private int status;

    /**
     * 推广排序值
     */
    private int rank;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "distributionGoods")
    List<DistributionGoodsAssign> assignList;

    @Transient
    @JsonIgnore
    private Double minPrice;

    @Transient
    @JsonIgnore
    private Double maxPrice;

    @Transient
    @JsonIgnore
    private Integer minScale;

    @Transient
    @JsonIgnore
    private Integer maxScale;

    /**
     * 商品id
     */
    @Transient
    @JsonIgnore
    private String goodsIds;

    /**
     * 分销商id
     */
    @Transient
    @JsonIgnore
    private String distributorIds;

}
